08. Garbage Collection
Title
Garbage Collection
ND079 JAVA C1 L2 A08 Garbage Collection
Every new object that we instantiate is added to the heap and consumes memory. In programming languages like C or C++, developers are responsible for creating and destroying objects. In contrast, Java has a background process called Garbage Collection (GC) that checks all instantiated objects, and destroys them if they do not have any references—thus freeing up memory, even without any active management on the part of the developer.
SOLUTION:
- Garbage collections runs as a background task.
- Developers do not need to take any action to make sure Garbage Collection removes unused Objects from Heap memory.
- Garbage Collection only removes objects that no longer have references to them.